package com.shanwen.shopping.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.shanwen.shopping.R;

/**
 * material design风格的common dialog
 *
 * @author 刘宾
 * @date 2015年12月13日 上午10:20:44
 */
public class QrCodeDialog
        extends Dialog {
    private Context context;
    private ImageView cancel;

    public QrCodeDialog(Context context) {
        super(context, R.style.CommonDialog_Dialog);
        this.context = context;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(context).inflate(R.layout.qrcode_dialog, null);
        setCancelable(false);
        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);
        dialogWindow.setWindowAnimations(R.style.dialogstyle);
        setContentView(view);
        initView(view);
        getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }

    private void initView(View view) {
        cancel = (ImageView) view.findViewById(R.id.cancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                QrCodeDialog.this.dismiss();
            }
        });
    }
}
